//
//  ZZPMusicCell.m
//  SlowPlay
//
//  Created by dllo on 15/10/21.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ZZPMusicCell.h"
#import "ZZPMusicModel.h"
@interface ZZPMusicCell ()
@property (nonatomic, strong) UIImageView *imageMusic;
@property (nonatomic, strong) UILabel *labelMusic;
@end
@implementation ZZPMusicCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createCell];
    }
    return self;
}
- (void)createCell
{
    _imageMusic = [[UIImageView alloc] initWithFrame:CGRectZero];
    
    [self.contentView addSubview:self.imageMusic];
    
    _labelMusic = [[UILabel alloc] initWithFrame:CGRectZero];
//    _labelMusic.backgroundColor = [UIColor redColor];
   _labelMusic.font = [UIFont systemFontOfSize:14];
    
    [self.contentView addSubview:self.labelMusic];
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    _imageMusic.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 20);
    
    _labelMusic.frame = CGRectMake(0, self.frame.size.height - 20, self.frame.size.width, 20);
}
// 重新model 的set方法
- (void)setModel:(ZZPMusicModel *)model
{
  
    _model = model;
    if (self.model.pic_url != nil) {
        
        [_imageMusic sd_setImageWithURL:[NSURL URLWithString:self.model.pic_url] placeholderImage:nil];
    }
    if (self.model.title != nil) {
        
        _labelMusic.text = self.model.title;
    }
}
@end
